package com.seven.bus.entity;

import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
public class BusInfoVO {

    private Integer id;

    private Date startTime;

    private Date endTime;

    private String endStation;
    private String address;
    private List<BusLineVO> line;

    public String getEndStation() {
        if (endStation == null && line != null) {
            endStation = line.get(line.size() - 1).getStation();
        }
        return endStation;
    }

    public String getAddress() {
        if (address == null && line != null) {
            StringBuilder stringBuilder = new StringBuilder();
            line.forEach(s-> stringBuilder.append(s.getStation()).append("=>"));
            address = stringBuilder.toString();
        }
        return address;
    }
}
